angular.module('mamApp').controller('newChannelModalController', ['$scope', 'PlayControlManager', '$state', '$uibModal','ImsDialog','$uibModalInstance','data',
    function ($scope, PlayControlManager, $state, $uibModal,ImsDialog,$uibModalInstance,data) {
        $scope.platformId=data.platformId;
        $scope.nameCheck=false;
        $scope.message="";

        $scope.cancel = function () {
            $uibModalInstance.dismiss("cancel");
        };
        $scope.table = JSON.parse(localStorage.getItem("codeTable"))

        $scope.formData={};
        $scope.formData.clientType=$scope.platformId;
        console.log(data)
        $scope.submit = function() {
            PlayControlManager.playChannelAdd($scope.formData).then(function (result) {
                if(result.data.c=="s"){
                    $uibModalInstance.close($scope.data);
                    $state.go('main.playPlan.playChannel.playChannelDetail',{'clientType':$scope.formData.clientType},{reload:true})
                }else{
                    $scope.nameCheck=true;
                    $scope.message=result.data.i;
                }
            })
        }
    }])

